package com.itheima.sh.service;

import com.itheima.sh.dao.LoginUser;
import com.itheima.sh.pojo.User;
import com.itheima.sh.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

/**
 * @author stay foolish
 * @description 行至水穷处, 坐看云起时
 * @date 2022/11/15 19:53:15
 * @description TODD
 */
public class UserServiceImpl {
    public User login(User user) {
        // 1.获取连接对象
        SqlSession sqlSession = SqlSessionUtil.getSqlSession();
        // 2.获取接口代理对象
        LoginUser mapper = sqlSession.getMapper(LoginUser.class);
        // 3.调用接口登录方法
        User u = mapper.login(user);
        // 4.释放资源
        sqlSession.close();
        // 5.返回查询到的用户对象给web层
        return u;
    }
}
